home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 4.0 KB | 152 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BmpFacet.cpp
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef BMPFACET_H
- #include "BmpFacet.h"
- #endif
-
- #ifndef BMPFRAME_H
- #include "BmpFrame.h"
- #endif
-
- #ifndef BMPPART_H
- #include "BmpPart.h"
- #endif
-
- #ifndef BMPSEL_H
- #include "BmpSel.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- // ----- Graphic Includes -----
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
- #include <ToolUtils.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
- #include <math routines.h>
- #endif
-
- #pragma segment bitmappart
-
- //========================================================================================
- // •• class CBitmapFacet
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::CBitmapFacet
- //----------------------------------------------------------------------------------------
-
- CBitmapFacet::CBitmapFacet()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::~CBitmapFacet
- //----------------------------------------------------------------------------------------
-
- CBitmapFacet::~CBitmapFacet()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::InitBitmapFacet
- //----------------------------------------------------------------------------------------
-
- void CBitmapFacet::InitBitmapFacet(XMPFacet* xmpFacet, CBitmapPart *bitmapPart)
- {
- this->InitFacet(xmpFacet);
- fBitmapPart = bitmapPart;
- }
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::Draw
- //----------------------------------------------------------------------------------------
-
- void CBitmapFacet::Draw(FW_CGraphicContext *gc)
- {
- FW_CBitmapShape bitmap = fBitmapPart->GetBitmapShape();
-
- FW_CRect frameRect;
- GetFrame()->GetFrameShapeBounds(&frameRect);
-
- // ----- Draw the bitmap -----
- bitmap->SetRectangle(frameRect);
- bitmap->Draw(gc);
-
- // ----- Draw the ants if there is a selection -----
- if (GetFrame()->IsActive())
- {
- CBitmapSelection *bitmapSelection = fBitmapPart->GetBitmapSelection();
- if (!bitmapSelection->IsEmpty())
- bitmapSelection->DoDrawAnts(gc);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBitmapFacet::DoMouseDown(const FW_CPoint& where, XMPEventData event)
- {
- FW_CPoint pt(where);
- FW_CPoint zoomRatio = GetZoomRatio();
- pt.x = ::FixDiv(pt.x, zoomRatio.x);
- pt.y = ::FixDiv(pt.y, zoomRatio.y);
-
- CBitmapSelection *bitmapSelection = fBitmapPart->GetBitmapSelection();
-
- // ----- If clicked into the selection start a drag -----
- if (bitmapSelection->InSelection(pt))
- {
- bitmapSelection->Drag(this, event);
- }
- else
- {
- // ----- Otherwise close the selection... -----
- {
- FW_CGraphicContext gc(*this);
- bitmapSelection->CloseSelection();
- }
-
- // ----- ... and start a track -----
- FW_CRect rect;
- if (bitmapSelection->Track(this, where, event, rect))
- {
- bitmapSelection->SetSelectRect(rect);
- bitmapSelection->DrawAnts(GetFrame());
- }
- }
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // • CBitmapFacet::GetZoomRatio
- //----------------------------------------------------------------------------------------
-
- FW_CPoint CBitmapFacet::GetZoomRatio() const
- {
- return ((CBitmapFrame*)GetFrame())->GetZoomRatio();
- }